home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 02 - 1986 / 02.07 Jul 86.sit / 02.07 Jul 86 / basic rescue source / It next >
Encoding:
Text File  |  1986-04-27  |  2.6 KB  |  104 lines  |  [TEXT/MSBB]

  1. REM}|{ Required marker for end of listing!!!
  2. '<<< Save on internal drive as 'It', Text format.
  3. '<<< Delete comments to save Memory.
  4. SUB Rescue STATIC
  5. CLEAR:Peekloc!=45000!
  6. DIM Keep%(18)
  7. PRINT:PRINT "Rescue engaged!"
  8.  
  9. '<<< Find location of {MERGE "It":} in memory
  10. ScanMem:
  11.   Peekloc!=Peekloc!+1
  12.   IF PEEK(Peekloc!)<>248 GOTO ScanMem
  13.   Flag%=0:RESTORE Peekvals
  14.   FOR I=1 TO 7
  15.     READ J%:IF PEEK(Peekloc!+I)<>J% THEN Flag%=1
  16.   NEXT I
  17.   IF Flag%=1 AND Peekloc!<127*1024 GOTO ScanMem
  18. Peekloc!=Peekloc!-4:Begin1!=Peekloc!:Begin2!=Peekloc!
  19. Peekvals:
  20.   DATA &H9E,&H20,&H22,&H49,&H74,&H22,&H3A
  21.  
  22. '<<< Recover decoded values and parameters
  23. OPEN "Garbage Bag" AS #1 LEN=174
  24. FIELD #1,128 AS N$,2 AS I$,4 AS T$,2 AS L$,36 AS k$,2 AS B$
  25.   GET #1,1
  26.   ID$=N$:Length%=CVI(I$)
  27.   Type$=T$:Keep%(0)=CVI(L$)
  28.   Kp$=k$:Pre%=CVI(B$)
  29. CLOSE #1
  30. KILL "Garbage Bag"
  31.  
  32. '<<< Write beginning of file
  33. ID$=LEFT$(ID$,Length%)+".IMOK"
  34. OPEN ID$ FOR OUTPUT AS #1
  35.   PRINT #1,CHR$(Pre%);
  36.   PRINT #1,CHR$(PEEK(Peekloc!+1));
  37.   PRINT #1,CHR$(Keep%(0));
  38.   PRINT #1,CHR$(PEEK(Peekloc!+3));
  39.   FOR I%=1 TO 18
  40.     Keep%(I%)=VAL("&H"+MID$(Kp$,2*I%-1,2))
  41.     PRINT #1,CHR$(Keep%(I%));
  42.   NEXT I%
  43. Peekloc!=Peekloc!+22:I%=0
  44.  
  45. '<<< Copy file until }|{ marker is reached, then
  46. '<<< skip to rescue5 if Program is version 2.0
  47. rescue1:
  48.   PRINT #1,CHR$(PEEK(Peekloc!));
  49.   Peekloc!=Peekloc!+1
  50.   IF PEEK(Peekloc!+2)<>&HAF THEN GOTO rescue1
  51.   Flag%=1
  52.   IF PEEK(Peekloc!+3)<>ASC("}") THEN Flag%=0
  53.   IF PEEK(Peekloc!+4)<>ASC("|") THEN Flag%=0
  54.   IF PEEK(Peekloc!+5)<>ASC("{") THEN Flag%=0
  55. IF Flag%=0 GOTO rescue1
  56. PRINT #1,CHR$(0);CHR$(0);
  57. IF Pre%>&HF7 GOTO rescue5
  58.  
  59. '<<< Make listing an Odd length
  60. Begin1!=Peekloc!-Begin1!
  61. Begin1!=Begin1!-1000*INT(Begin1!/1000)
  62. IF (1 AND INT(Begin1!))=0 THEN PRINT #1,CHR$(0);
  63.  
  64. '<<< Find end of variable names using: TenZZZ...Z
  65. '<<< This var MUST NOT appear anywhere else:
  66. TenZZZZZZZZZZ=0
  67. rescue3:
  68.   Peekloc!=Peekloc!+1
  69.   IF PEEK(Peekloc!)<>ASC("Z") GOTO rescue3
  70.   Flag%=1
  71.   FOR I%=1 TO 9
  72.     IF PEEK(Peekloc!+I%)<>ASC("Z") THEN Flag%=0
  73.   NEXT I%
  74. IF Flag%=0 GOTO rescue3
  75. J=Peekloc!+10
  76.  
  77. '<<< Backtrack to start of variables list.
  78. rescue4:
  79.   Peekloc!=Peekloc!-1
  80.   IF PEEK(Peekloc!-1)<>&H0 GOTO rescue4
  81. J=J-Peekloc!-4
  82.  
  83. '<<< If total listing is odd, skip first position.
  84. Begin2!=Peekloc!-Begin2!
  85. Begin2!=Begin2!-1000*INT(Begin2!/1000)
  86. IF (1 AND INT(Begin2!))=0 THEN Peekloc!=Peekloc!+1
  87.  
  88. '<<< Print Variables table, EXCEPT: TenZ...ZZ
  89. WHILE J>1
  90.   PRINT #1,CHR$(PEEK(Peekloc!));
  91.   Peekloc!=Peekloc!+1:J=J-1
  92. WEND
  93.  
  94. rescue5:
  95. PRINT "Voil"+CHR$(136)+"! Rescue Completed!"
  96.   CLOSE #1
  97.   NAME ID$ AS ID$,Type$
  98. PRINT "Now loading into memory."
  99. PRINT "Recommend you first use"
  100. PRINT "'Save As' to save file...";
  101. BEEP:FOR I%=1 TO 20000:NEXT I%
  102. LOAD ID$
  103. END SUB
  104.